package com.sikaryofficial.backend.domain.dto.resp.productactivity;

import com.sikaryofficial.backend.constant.ActivityStatusEnum;
import com.sikaryofficial.backend.constant.ActivityTypeEnum;
import com.sikaryofficial.common.core.annotation.LocalDateTimeFormat;
import com.sikaryofficial.system.api.model.AddressDTO;
import com.sikaryofficial.system.api.model.att.AttachmentResp;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * @author : qinjinyuan
 * @desc : 活动响应对象
 * @date : 2023/11/21 19:30
 */
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(description = "活动响应对象")
public class ActivityDTO {

    @ApiModelProperty(value = "序列号")
    private Integer seqNo;

    /**
     * 活动ID
     */
    @ApiModelProperty(value = "活动ID")
    private Long activityId;

    /**
     * 活动名称
     */
    @ApiModelProperty(value = "活动名称")
    private String activityName;

    /**
     * 活动描述
     */
    @ApiModelProperty(value = "活动描述")
    private String activityDesc;

    /**
     * 活动开始时间
     */
    @ApiModelProperty(value = "活动开始时间", example = "2023-11-21 19:30:00")
    @LocalDateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;

    /**
     * 活动结束时间
     */
    @ApiModelProperty(value = "活动结束时间", example = "2023-11-22 19:30:00")
    @LocalDateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;

    @ApiModelProperty(value = "活动封面图片")
    private String coverUrl;

    @ApiModelProperty(value = "活动封面图片列表")
    private List<AttachmentResp> coverUrlList;

    /**
     * 1-purchase 抢购 2-lottery 抽奖 3-auction 竞拍
     */
    @ApiModelProperty(value = "1-purchase 抢购 2-lottery 抽奖 3-auction 竞拍")
    private Integer activityType;

    public String getActivityTypeDesc() {
        if (Objects.isNull(activityType) || Objects.isNull(ActivityTypeEnum.getNameByCode(activityType))) {
            return "";
        }
        return ActivityTypeEnum.getNameByCode(activityType).getDesc();
    }

    /**
     * 活动是否上架（生效）0-否 1-是
     */
    @ApiModelProperty(value = "活动是否上架（生效）0-否 1-是")
    private Integer hasEffect;

    /**
     * 活动创建时间
     */
    @ApiModelProperty(value = "活动创建时间 yyyy-MM-dd HH:mm:ss")
    @LocalDateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createdTime;

    /**
     * 国家
     */
    @ApiModelProperty(value = "国家", example = "UnitedKingdom")
    private String country;

    /**
     * 城市
     */
    @ApiModelProperty(value = "城市", example = "Barnsley")
    private String city;

    /**
     * 区域
     */
    @ApiModelProperty(value = "区域", example = "England")
    private String area;

    /**
     * 地址ID
     */
    @ApiModelProperty(value = "地址ID")
    private Long addressId;

    /**
     * 地址对象
     */
    @ApiModelProperty(value = "地址对象")
    private AddressDTO address;
    /**
     * 活动(平台)品牌
     */
    @ApiModelProperty(value = "活动(平台)品牌")
    private String activityBrand;

    /**
     * 预约数量
     */
    @ApiModelProperty(value = "预约数量")
    private Integer reserveNum;

    /**
     * 抢购数量
     */
    @ApiModelProperty(value = "抢购数量")
    private Integer purchaseNum;

    /**
     * 积分个数
     */
    @ApiModelProperty(value = "积分个数")
    private Integer points;

    @ApiModelProperty(value = "活动状态 1-可预约 ;2-活动进行中 ;3-活动结束或下架")
    private Integer activityStatus;

    @ApiModelProperty(value = "预约状态：0-未预约, 1-reserved已预约, 2-expired已过期")
    private Integer reserveStatus;

    @ApiModelProperty(value = "活动状态描述")
    private String activityStatusDesc;

    /**
     * 是否推荐首页 0-否 1-是，默认0
     */
    @ApiModelProperty(value = "是否推荐首页 0-否 1-是，默认0")
    private Integer hasHomepage;

    @ApiModelProperty(value = "活动附件列表")
    private List<AttachmentResp> attachmentList;

    /**
     * 是否有我的收藏
     */
    @ApiModelProperty(value = "是否有我的收藏")
    private boolean hasOwnerCollection;


    public String getActivityStatusDesc() {
        if (Objects.isNull(activityStatus)) {
            return null;
        }
        if (Objects.nonNull(ActivityStatusEnum.getNameByCode(activityStatus))) {
            return ActivityStatusEnum.getNameByCode(activityStatus).getName();
        }
        return null;
    }

    @ApiModelProperty(value = "抢购结果:true 抢购成功，false 抢购失败",example = "true")
    private Boolean attendResult;

    private Integer tenantId;

    @ApiModelProperty(value = "活动奖品关系列表")
    private List<ActivityPrizeRelationDTO> activityPrizeRelationList;

    /**
     * 是否隐藏活动 0-显示 1-隐藏，默认0-显示
     */
    @ApiModelProperty(value = "是否隐藏活动 0-显示 1-隐藏，默认0-显示")
    private Integer hasHide;

    @ApiModelProperty(value = "活动参与次数")
    private Integer attendNumber;

    @ApiModelProperty(value = "活动参与人数")
    private Integer attendPeopleNumber;

    @ApiModelProperty(value = "是否线上活动 0-线上 1-线下，默认线上活动")
    private Integer hasOnline;
}
